<?php 
class dv_model extends CI_Model {
        function __construct()
        {
                parent::__construct();        
                $this->load->helper("local");
                $this->load->helper('date');
                $this->load->database();
        } 
//START-----------------dv-------------------------//              
		function get_all_dv()
        {
			 $this->load->database();
             $query = $this->db->query("select * from dv_profile order by dv_company_name ASC");
			return $query->result();
        }
		
	   function getdvSearchBydv_company_name($comp_name)
       {       $query = $this->db->query ("select * from dv_profile where dv_company_name like '%$comp_name%' order by dv_company_name ASC Limit 10");
				return $query->result();
       }
	   	
        function getdv_info($code)
        {        
                $query = $this->db->query("select *from dv_profile where driver_code='$code'");
                 //return $query->result();
				 return $query->row();
        }
		function getatInfoby_dv_company_name($dv_company_name)
        {       $query = $this->db->query ("select * from dv_profile where dv_company_name='$dv_company_name' ");
				return $query->row();
        }
   function search($terms)
    {
        // Execute our SQL statement and return the result
        $sql = "SELECT url, dv_company_name
                    FROM dv_profile
                    WHERE MATCH (dv_company_name) AGAINST (?) > 0";
        $query = $this->db->query($sql, array($terms, $terms));
        return $query->result();
    }
/*
function search($terms, $start = 0, $results_per_page = 0)
	{
		// Determine whether we need to limit the results
		if ($results_per_page > 0)
		{
			$limit = "LIMIT $start, $results_per_page";
		}
		else
		{
			$limit = '';
		}
		
		// Execute our SQL statement and return the result
		$sql = "SELECT url, title, content
				FROM pages
				WHERE MATCH (content) AGAINST (?) > 0
				$limit";
		$query = $this->db->query($sql, array($terms, $terms));
		return $query->result();
	}
	
	/**
	 * Determine the total number of results that will be returned by a seach
	 * on the specified search terms.
	 *
	 * @param string $terms The search terms.
	 * @return integer Total number of search results.
	 * @author Joe Freeman
	 *//*
	function count_search_results($terms)
	{
		// Run SQL to count the total number of search results
		$sql = "SELECT COUNT(*) AS count
				FROM pages
				WHERE MATCH (content) AGAINST (?)";
		$query = $this->db->query($sql, array($terms));
		return $query->row()->count;
	}*/
//End-----------------dv -------------------------//              		

}
?>
